package org.eztouch.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/userService")
public class UserServiceController {
	
	@Autowired
	private DiscoveryClient client;
	
	@RequestMapping(value = "/getUserById" ,method = RequestMethod.GET)
	public String getUserById(@RequestParam String userId){
		ServiceInstance instance = client.getLocalServiceInstance();
		
		System.out.println("ServiceId="+instance.getServiceId()+"，Host:"+instance.getHost()+"，Port="+instance.getPort()+"，Uri="+instance.getUri());
		System.out.println("接收到的参数：userId="+userId);
		
		return "user.userId="+userId;
	}
	
}
